<div class="x-body">
    <form class="layui-form layui-form-pane" id="AdminRoleEdit" lay-filter="AdminRoleEdit">
        <input type="hidden" name="id" value="">
        <input type="hidden" name="layerindex" id="layerindex" value="">
        <input type="hidden" name="layerindex" id="layerindex" value="">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>角色名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="title" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text" style="height:400px;overflow:scroll">
            <label class="layui-form-label">拥有权限 </label>
            <table class="layui-table layui-input-block site-table">
                <tbody>
                    <volist name="nodelist" id="vo">
                        <tr>
                            <td width="100">

                                <?php 
                                $ff=in_array($vo['id'],$role['rules']);
                                if ($ff) {
                                ?>
                                <input name="nodeid[]" type="checkbox" checked="checked" value="<?php echo $vo['id']; ?>"><?php echo $vo['title']; ?>
                                <?php }else{?>
                                <input name="nodeid[]" type="checkbox" value="<?php echo $vo['id']; ?>"><?php echo $vo['title']; ?>
                                <?php }?>
                            </td>
                            <td>
                                <table class="layui-table layui-input-block site-table">
                                    <tbody>
                                        <volist name="vo['child']" id="ch">
                                            <tr>
                                                <td width="120">
                                                    <?php 
                                                    if (in_array($ch['id'],$role['rules'])) {
                                                    ?>
                                                    <input name="nodeid[]" type="checkbox" checked value="<?php echo $ch['id']; ?>"><?php echo $ch['title']; ?></td>
                                                    <?php }else{?>
                                                <input name="nodeid[]" type="checkbox" value="<?php echo $ch['id']; ?>"><?php echo $ch['title']; ?></td>
                                                <?php }?>
                            <td>
                                <div class="layui-input-block">
                                    <volist name="ch['child']" id="child">
                                            <?php 
                                            if (in_array($child['id'],$role['rules'])) {
                                            ?>
                                            <input name="nodeid[]" type="checkbox" checked value="<?php echo $child['id']; ?>"><?php echo $child['title']; ?>
                                            <?php }else{?>
                                        <input name="nodeid[]" type="checkbox" value="<?php echo $child['id']; ?>"><?php echo $child['title']; ?>
                                        <?php }?>
                                    </volist>
                                </div>
                            </td>
                            </tr>
                            </volist>
                            </tbody>
                            </table>
                            </td>
                        </tr>
                    </volist>
                </tbody>
            </table>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="desc" class="layui-form-label">
                描述
            </label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" name="remark" class="layui-textarea">{$role['remark']}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="add">保存</button>
        </div>
    </form>
</div>
<script>
    form.render(null, 'AdminRoleEdit');
    form.on('submit(add)', function (data) {
        $.ajax({
            url: '{:U("Role/edit")}',
            type: "post",
            data: data.field,
            dataType: 'json',
            success: function (r) {
                layer.msg(r.info);
                if (r.status) {
                    layer.close($('#layerindex').val());
                    table.reload('AdminRoleDt');
                }
            }
        });
        return false;
    });
</script>